package cn.sxw.android.base.ui;

import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.StrictMode;

import com.zcs.autolayout.config.AutoLayoutConfig;

import cn.sxw.android.base.utils.CrashHandler;
import cn.sxw.android.base.utils.JColors;

public abstract class BaseApplication extends Application {
    private static BaseApplication mApplication;

    @Override
    public void onCreate() {
        super.onCreate();
        mApplication = this;
        AutoLayoutConfig.getInstance().useDeviceSize().useLandscape();

        //初始化CrashHandler
        CrashHandler.getInstance().init(this);
        JColors.init(getApplicationContext());
        /**
         * TODO 解决android7.0以上版本传递URI问题
         * @Modify by zzy@sxw.cn on 2018/2/8
         */
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.setVmPolicy(builder.build());
        }
        // 初始化X5浏览器
        // X5TbsUtils.init();
    }

    /**
     * 程序终止的时候执行
     */
    @Override
    public void onTerminate() {
        super.onTerminate();
        mApplication = null;
    }

    /**
     * 返回上下文
     *
     * @return
     */
    public static Context getContext() {
        return mApplication;
    }
}
